home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 February: Tool Chest / Dev.CD Feb 97 TC.toast / Sample Code / Overview / System 7.0 Samples / ProcDoggie 1.0a6 / UProcessGuts.p < prev    next >
Encoding:
Text File  |  1994-11-18  |  13.9 KB  |  358 lines  |  [TEXT/MPS ]

  1. UNIT UProcessGuts;
  2.  
  3. {-------------------------------------------------------------------------------
  4. #
  5. #    Apple Macintosh Developer Technical Support
  6. #
  7. #    Interfaces for the guts of the ProcDoggie application
  8. #
  9. #    Program:    ProcDoggie
  10. #    File:        UProcessGuts.p - Pascal Implementation
  11. #
  12. #    by:        Forrest Tanaka
  13. #
  14. #    Copyright © 1988-1991 Apple Computer, Inc.
  15. #    All rights reserved.
  16. #
  17. --------------------------------------------------------------------------------
  18. #
  19. #    Process Manager-related code that’s specific to ProcDoggie is contained in
  20. #    this unit.  Mainly, this code handles the user interface aspects of this
  21. #    program that relate to the Process Manager, such as the Process List window,
  22. #    the Process Information windows, and most of the menus.
  23. #
  24. #    The Process List window displays a list of all active processes.  It allows
  25. #    the user to click on one or more of the process names and then use menu
  26. #    commands to operate on those selected processes.
  27. #
  28. #    Process Information windows display information about the selected active
  29. #    processes.  The information includes the process’s name, type, creator, SIZE
  30. #    resource flags, partition size, and free memory availability.
  31. #
  32. #    When the user chooses to launch an application, routines in this unit are
  33. #    called to ask the user what process to launch and optionally what documents
  34. #    to open or print, depending on the current launch mode.
  35. #
  36. #    This unit also maintains the current launch mode.  The launch mode indicates
  37. #    whether the user wants to simply launch an application, launch an application
  38. #    along with documents to open, and launch an application with documents to
  39. #    print.  The launch mode is global for this application, and affects the way
  40. #    the menu commands that launch applications work.
  41. #
  42. -------------------------------------------------------------------------------}
  43. {[j=20/57/1$] Pasmat Options}
  44.  
  45.  
  46. INTERFACE
  47.  
  48.  
  49. (*******************************************************************************
  50. * Units
  51. *******************************************************************************)
  52.  
  53.     USES
  54.         (* Group 1 *)
  55.          Types
  56.         ,QuickDraw
  57.  
  58.         (* Group 2 *)
  59.         ,AppleEvents
  60.         ,Controls
  61.         ,Errors
  62.         ,Events
  63.         ,GestaltEqu
  64.         ,Memory
  65.         ,Menus
  66.         ,OSUtils
  67.         ,Resources
  68.         ,SegLoad
  69.         ,LowMem
  70.         ,ToolUtils
  71.         ,TextUtils
  72.  
  73.         (* Group 3 *)
  74.         ,Aliases
  75.         ,Files
  76.         ,Lists
  77.         ,Processes
  78.         ,Script
  79.         ,Windows
  80.  
  81.         (* Group 4 *)
  82.         ,Dialogs
  83.         ,Palettes
  84.         ,StandardFile
  85.  
  86.         (* Group 5 *)
  87.         ,Packages
  88.  
  89.         (* Application *)
  90.         ,UGlobals
  91.         ,UDialogUtils
  92.         ,UEmergMem
  93.         ,UProcessUtils
  94.         ,UMenuHandler
  95.         ,UProcessLDEF
  96.         ;
  97.  
  98.  
  99. (*******************************************************************************
  100. * SetLaunchMode - Set the launch mode
  101. *
  102. * This routine is called to set the launching mode to the mode specified by the
  103. * "newMode" parameter.  A launch mode of "kJustLaunch" simply launches an
  104. * application or desk accessory, "kOpenLaunch" launches an application with one
  105. * or more documents for the launched application to open, "kPrintLaunch"
  106. * launches an application with one or more documents for the launched
  107. * application to print.  The launch modes are declared in UProcessUtils.p.
  108. *******************************************************************************)
  109.  
  110.     PROCEDURE SetLaunchMode (newMode: LaunchModeCode);
  111.  
  112.  
  113. (*******************************************************************************
  114. * GetLaunchMode - Get the launch mode
  115. *
  116. * The current launch mode is returned.  For details about launching modes, see
  117. * the description of the SetLaunchMode routine.
  118. *******************************************************************************)
  119.  
  120.     FUNCTION GetLaunchMode: LaunchModeCode;
  121.  
  122.  
  123. (*******************************************************************************
  124. * IsProcessListWindow - Is a WindowPtr a pointer to a process list window?
  125. *
  126. * When I want to find out whether a window that I have a pointer to is a process
  127. * list window or not, I call this routine.  It returns TRUE if aWindow is a
  128. * pointer to a process list window, FALSE if it isn’t.  If aWindow is NIL, then
  129. * IsProcessListWindow returns FALSE.
  130. *******************************************************************************)
  131.  
  132.     FUNCTION IsProcessListWindow (aWindow: WindowPtr): Boolean;
  133.  
  134.  
  135. (*******************************************************************************
  136. * CreateProcessListWindow - Create a process list window
  137. *
  138. * This routine is called to create a new Process List window visible and
  139. * centered on the main screen.  A pointer to the window is returned.  If there
  140. * isn’t enough memory for the window, or if some other problem happened to make
  141. * it impossible to create the window, then CreateProcessListWindow puts up an
  142. * alert indicating this to the user, and then it returns NIL.
  143. *******************************************************************************)
  144.  
  145.     FUNCTION CreateProcessListWindow: WindowPtr;
  146.  
  147.  
  148. (*******************************************************************************
  149. * IdleProcessListWindow - Keep the process list window up to date
  150. *
  151. * IdleProcessListWindow updates the process list window specified by
  152. * processListWindow so that it reflects the status of the processes that are
  153. * currently open.  It’s called once per main event loop iteration.
  154. *******************************************************************************)
  155.  
  156.     PROCEDURE IdleProcessListWindow (processListWindow: WindowPtr);
  157.  
  158.  
  159. (*******************************************************************************
  160. * DrawProcessListWindow - Draw the contents of the process list window
  161. *
  162. * Whenever an update event is received for the process list window, the routine
  163. * is called to draw into the window.  Since the process list covers the entire
  164. * window, the only thing to be done is to call the List Manager to draw the
  165. * list.  processListWindow is a pointer to the process list window.
  166. *******************************************************************************)
  167.  
  168.     PROCEDURE DrawProcessListWindow (processListWindow: WindowPtr);
  169.  
  170.  
  171. (*******************************************************************************
  172. * ClickProcessListWindow - Handle a mouse click in the process list window
  173. *
  174. * When a mouse click is detected in the content region of the process list
  175. * window specified by processListWindow, this routine is called to handle it.
  176. * It allows the user to select a process or several processes in the list.  If
  177. * the user double-clicks on a process, then that process and any other selected
  178. * processes are brought to the front.
  179. *
  180. * clickEvent is the mouse-down event that was in the process list window.
  181. *******************************************************************************)
  182.  
  183.     PROCEDURE ClickProcessListWindow (processListWindow: WindowPtr;
  184.                                       clickEvent:        EventRecord);
  185.  
  186.  
  187. (*******************************************************************************
  188. * ActivateProcessListWindow - Handle an activate/deactivate event
  189. *
  190. * Whenever an activate or deactivate event is received for the process list
  191. * window specified by processListWindow, this routine is called to handle the
  192. * event.  If the event was an activate event, then becomingActive is TRUE.  If
  193. * the event was a deactivate event, then becomingActive is FALSE.
  194. *******************************************************************************)
  195.  
  196.     PROCEDURE ActivateProcessListWindow (processListWindow: WindowPtr;
  197.                                          becomingActive:    Boolean);
  198.  
  199.  
  200. (*******************************************************************************
  201. * FixProcessListMenus - Undim menu items for process list window
  202. *
  203. * Any menus that should be available when the process list window is in front
  204. * are undimmed if the current conditions are appropriate.
  205. *******************************************************************************)
  206.  
  207.     PROCEDURE FixProcessListMenus (processListWindow: WindowPtr);
  208.  
  209.  
  210. (*******************************************************************************
  211. * IsProcessInfoWindow - Is a WindowPtr a pointer to a process info window?
  212. *
  213. * When I want to find out whether a window that I have a pointer to is a process
  214. * info window or not, I call this routine.  It returns TRUE if aWindow is a
  215. * pointer to a process info window, FALSE if it isn’t.  If aWindow is NIL, then
  216. * IsProcessInfoWindow returns NIL.
  217. *******************************************************************************)
  218.  
  219.     FUNCTION IsProcessInfoWindow (aWindow: WindowPtr): Boolean;
  220.  
  221.  
  222. (*******************************************************************************
  223. * IdleProcessInfoWindow - Give the specified process info window some idle time
  224. *
  225. * This routine is called once per event loop iteration.  It gives the specified
  226. * process info window some idle time to update the memory indicator.
  227. *******************************************************************************)
  228.  
  229.     PROCEDURE IdleProcessInfoWindow (processInfoWindow: WindowPtr);
  230.  
  231.  
  232. (*******************************************************************************
  233. * DrawProcessInfoWindow - Draw the contents of the process info window
  234. *
  235. * Whenever an update event is received for the process info window, the routine
  236. * is called to draw the static items into the window.
  237. *******************************************************************************)
  238.  
  239.     PROCEDURE DrawProcessInfoWindow (processInfoWindow: WindowPtr);
  240.  
  241.  
  242. (*******************************************************************************
  243. * FixProcessInfoMenus - Undim menu items for process information window
  244. *
  245. * Any menus that should be available when a process information window is in
  246. * front are undimmed if the current conditions are appropriate.
  247. *******************************************************************************)
  248.  
  249.     PROCEDURE FixProcessInfoMenus (processInfoWindow: WindowPtr);
  250.  
  251.  
  252. (*******************************************************************************
  253. * CloseProcessInfoWindow - Close a process info window
  254. *
  255. * The process info window specified by "processInfoWindow" is closed and all its
  256. * associated memory is deallocated.
  257. *******************************************************************************)
  258.  
  259.     PROCEDURE CloseProcessInfoWindow (processInfoWindow: WindowPtr);
  260.  
  261.  
  262. (*******************************************************************************
  263. * IdleAllProcessWindows - Give every open process window idle time
  264. *
  265. * IdleAllProcessWindows is called to give the process list window and all open
  266. * process info windows some idle time.  This routine is called once per main
  267. * event loop iteration.
  268. *******************************************************************************)
  269.  
  270.     PROCEDURE IdleAllProcessWindows;
  271.  
  272.  
  273. (*******************************************************************************
  274. * DoLaunchInFront - Launch a process to the front
  275. *
  276. * When the user wants to launch a process and have it brought to the front, this
  277. * routine is called.  It allows the user to choose a process through Standard
  278. * File.  That application is then launched and brought to the front.
  279. *******************************************************************************)
  280.  
  281.     PROCEDURE DoLaunchInFront;
  282.  
  283.  
  284. (*******************************************************************************
  285. * DoLaunchInBack - Launch a process to the back
  286. *
  287. * When the user wants to launch a process and have it sent to the back of all of
  288. * the open processes, this routine is called.  It allows the user to choose a
  289. * process through Standard File.  That process is then launched and sent to the
  290. * back.
  291. *******************************************************************************)
  292.  
  293.     PROCEDURE DoLaunchInBack;
  294.  
  295.  
  296. (*******************************************************************************
  297. * DoLaunchTo - Launch a process and terminate self
  298. *
  299. * When the user wants to launch a process and then immediately quit ProcDoggie,
  300. * this routine is called.  It allows the user to choose a process through
  301. * Standard File.  That process is then launched and brought to the front, and
  302. * then ProcDoggie is immediately terminated.
  303. *******************************************************************************)
  304.  
  305.     PROCEDURE DoLaunchTo;
  306.  
  307.  
  308. (*******************************************************************************
  309. * DoLaunchMode - Handle Simple Launch, Open on Launch, Print on Launch commands
  310. *
  311. * This routine is called when a launch mode menu item is chosen.  The launch
  312. * mode items are in the file menu and are the “Simple Launch,” “Open Documents
  313. * on Launch,” and “Print Documents on Launch” items.
  314. *******************************************************************************)
  315.  
  316.     PROCEDURE DoLaunchMode (modeItem: Integer);
  317.  
  318.  
  319. (*******************************************************************************
  320. * DoBringProcessToFront - Bring an open process to the front
  321. *
  322. * When the user chooses the Bring to Front menu item, this routine is called to
  323. * bring all the selected process to the front in the order that they appear in
  324. * the process list window specified by processListWindow.  For the moment, it
  325. * won’t bring it’s own application (ProcDoggie) to the front.  I don’t know how
  326. * or whether I’ll be able to fix that.
  327. *******************************************************************************)
  328.  
  329.     PROCEDURE DoBringProcessToFront (processListWindow: WindowPtr);
  330.  
  331.  
  332. (*******************************************************************************
  333. * DoGetProcessInfo - Get information about selected processes
  334. *
  335. * This routine is called when the user desires information about the processes
  336. * selected in the process list window specified by the "processListWindow"
  337. * parameter.
  338. *******************************************************************************)
  339.  
  340.     PROCEDURE DoGetProcessInfo (processListWindow: WindowPtr);
  341.  
  342.  
  343. (*******************************************************************************
  344. * DoTerminateProcess - Terminate the selected processes
  345. *
  346. * This routine is called when the user wants to terminate the processes selected
  347. * in the process list window specified by the "processListWindow" parameter.
  348. *******************************************************************************)
  349.  
  350.     PROCEDURE DoTerminateProcess (processListWindow: WindowPtr);
  351.  
  352.  
  353. IMPLEMENTATION
  354.  
  355.     {$I UProcessGuts.inc1.p}
  356.  
  357. END.
  358.